<!DOCTYPE html>
<html lang="zh-cn"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>micServiceServer 微服务系统</title>
    <script>
        if (window != window.top) top.location.href = self.location.href;
    </script>
    <link rel="icon" type="image/x-icon" href="../img/favicon.ico">
    <link href="../plugins/layui/css/layui.css" rel="stylesheet" />
    <link href="../plugins/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <link href="../build/css/login.css" rel="stylesheet" />
    <link href="../plugins/sideshow/css/normalize.css" rel="stylesheet" />
    <link href="../plugins/sideshow/css/demo.css" rel="stylesheet" />
    <link href="../plugins/sideshow/css/component.css" rel="stylesheet" />
    <!--[if IE]>
        <script src="../plugins/sideshow/js/html5.js"></script>
    <![endif]-->
    <style>
        canvas {
            position: absolute;
            z-index: -1;
        }
        
        .kit-login-box header h1 {
            line-height: normal;
        }
        
        .kit-login-box header {
            height: auto;
        }
        
        .content {
            position: relative;
        }
        
        .codrops-demos {
            position: absolute;
            bottom: 0;
            left: 40%;
            z-index: 10;
        }
        
        .codrops-demos a {
            border: 2px solid rgba(242, 242, 242, 0.41);
            color: rgba(255, 255, 255, 0.51);
        }
        
        .kit-pull-right button,
        .kit-login-main .layui-form-item input {
            background-color: transparent;
            color: white;
        }
        
        .kit-login-main .layui-form-item input::-webkit-input-placeholder {
            color: white;
        }
        
        .kit-login-main .layui-form-item input:-moz-placeholder {
            color: white;
        }
        
        .kit-login-main .layui-form-item input::-moz-placeholder {
            color: white;
        }
        
        .kit-login-main .layui-form-item input:-ms-input-placeholder {
            color: white;
        }
        
        .kit-pull-right button:hover {
            border-color: #009688;
            color: #009688
        }
    </style>
</head>


<body class="kit-login-bg">
    <div class="container demo-1">
        <div class="content">
            <div id="large-header" class="large-header">
                <canvas id="demo-canvas"></canvas>
                <div class="kit-login-box">
                    <header>
                        <h1>micServiceServer 登录</h1>
                    </header>
                    <div class="kit-login-main">
                        <div action="/admin/login" class="layui-form" method="post">
                            <div class="layui-form-item">
                                <label class="kit-login-icon">
                                    <i class="layui-icon">&#xe612;</i>
                                </label>
                                <input type="text" name="username" lay-verify="required" autocomplete="off" placeholder="这里输入用户名." class="layui-input">
                            </div>
                            <div class="layui-form-item">
                                <label class="kit-login-icon">
                                    <i class="layui-icon">&#xe642;</i>
                                </label>
                                <input type="password" name="password" lay-verify="required" autocomplete="off" placeholder="这里输入密码." class="layui-input">
                            </div>
                            <div class="layui-form-item">
                                <div class="kit-pull-left kit-login-remember">
                                    <input type="checkbox" name="rememberMe" value="true" lay-skin="primary" title="记住帐号?">
                                </div>
                                <div class="kit-pull-right">
                                    <button class="layui-btn layui-btn-primary" id="register">
                                        <i class="fa fa-registered" aria-hidden="true"></i> 注册
                                    </button>
                                    <button class="layui-btn layui-btn-primary" lay-submit lay-filter="login">
                                        <i class="fa fa-sign-in" aria-hidden="true"></i> 登录
                                    </button>
                                </div>
                                <div class="kit-clear"></div>
                            </div>
                        </div>
                    </div>
                    <footer>
                        <p>micServiceServer © <a href="https://gitee.com/wusq/micServiceServer" style="color:white; font-size:18px;" target="_blank">gitee</a></p>
                    </footer>
                </div>
            </div>
        </div>
    </div>
    <!-- /container -->

    <script src="../plugins/layui/layui.js"></script>
    <script src="../plugins/sideshow/js/TweenLite.min.js"></script>
    <script src="../plugins/sideshow/js/EasePack.min.js"></script>
    <script src="../plugins/sideshow/js/rAF.js"></script>
    <script src="../plugins/sideshow/js/demo-1.js"></script>
    <script>
        layui.use(['layer', 'form'], function() {
            var layer = layui.layer,
                $ = layui.jquery,
                form = layui.form,
                registerLayer=null;

            //清理左侧菜单缓存
            var index = layer.load(2, {
                shade: [0.3, '#333']
            });

            $(window).on('load', function() {
                layer.close(index);
                form.on('submit(login)', function(data) {
                    var loadIndex = layer.load(2, {
                        shade: [0.3, '#333']
                    });
                     $.post("/admin/login", data.field, function(res) {
                         if(res.code==1){
                             layer.msg(res.msg, {
                                 icon: 1
                             });
                             location.href = '/admin/index';
                         }else{
                             layer.msg(res.msg, {
                                 icon: 2
                             });
                         }
                         loadIndex && layer.close(loadIndex);
                     }, 'json');
                });

                form.on('submit(registerSubmit)', function(data) {
                    var loadIndex = layer.load(2, {
                        shade: [0.3, '#333']
                    });
                     $.post("/admin/register", data.field, function(res) {
                         layer.msg(res.msg, {
                             icon: 1
                         });
                         loadIndex && layer.close(loadIndex);
                         layer.close(registerLayer);
                     }, 'json');
                });
            }());

            form.verify({
                username: function(value, item){ //value：表单的值、item：表单的DOM对象
                    if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
                        return '用户名不能有特殊字符';
                    }
                    if(/(^\_)|(\__)|(\_+$)/.test(value)){
                        return '用户名首尾不能出现下划线\'_\'';
                    }
                    if(/^\d+\d+\d$/.test(value)){
                        return '用户名不能全为数字';
                    }
                }

                //我们既支持上述函数式的方式，也支持下述数组的形式
                //数组的两个值分别代表：[正则匹配、匹配不符时的提示文字]
                ,pass: [
                    /^[\S]{6,12}$/
                    ,'密码必须6到12位，且不能出现空格'
                ]
            });

            $("#register").on("click",function () {
                registerLayer=layer.open({
                   type:1,
                    area:'30%',
                    offset:'20%',
                    maxmin:true,
                    skin:'layui-layer-molv',
                    content:$("#registerForm")
                });
            });
        });
    </script>
</body>
<div id="registerForm" style="margin-top:30px;width:95%;display: none">
    <div action="/admin/register" class="layui-form" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 20%">用户名</label>
            <div class="layui-input-block">
                <input type="text" name="username" lay-verify="required|username" autocomplete="off" placeholder="请输入用户名" class="layui-input"  style="width:90%">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 20%">真实姓名</label>
            <div class="layui-input-block">
                <input type="text" name="realname" lay-verify="required|username" autocomplete="off" placeholder="请输入真实姓名" class="layui-input"  style="width:90%">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 20%">密码</label>
            <div class="layui-input-block">
                <input type="password" name="password" lay-verify="required|pass" autocomplete="off" placeholder="请输入密码" class="layui-input"  style="width:90%">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 20%">确认密码</label>
            <div class="layui-input-block">
                <input type="password" name="confirmPassword" lay-verify="required|pass" autocomplete="off" placeholder="请输入确认密码" class="layui-input"  style="width:90%">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 20%">邮箱</label>
            <div class="layui-input-block">
                <input type="email" name="email" lay-verify="email|required" autocomplete="off" placeholder="请输入公司邮箱" class="layui-input"  style="width:90%">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-radius" lay-submit lay-filter="registerSubmit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-radius">重置</button>
            </div>
        </div>
    </div>
</div>

</html>